package com.example.demo1.objects;


import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component // 有它能返回json，字段不一定有，取决于字段提供方式：public 属性或者public getter
public class ReturnObject1 {
    @Value("111")
    private int a;

    @Value("bbb")
    private String b;

    // 返回json 字段名aa
    public int aa;

    // 有它能返回json 字段，否则不返回json 字段
    public int getAXX() {
        return 100;
    }
    // 返回字段名，若和属性重复，则字段值被函数返回值覆盖
    public int getAa() {
        return 1000;
    }

    public String toString()
    {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("a", getAXX())
                .append("b", getAa())
                .toString();
    }
}



